 package server.console.groups.cashshop;









import com.alee.laf.panel.WebPanel;
import com.alee.laf.rootpane.WebFrame;
import com.alee.laf.text.WebTextArea;
import com.alee.laf.text.WebTextField;
import com.alibaba.druid.pool.DruidPooledConnection;
import database.DatabaseConnection;
import server.console.Start;

import java.awt.*;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Random;


















 public class CashCodeGeneratePane extends WebFrame {
/*  26 */   private static final WebTextField 面值 = new WebTextField(8); private static final WebTextField 数量 = new WebTextField(4);
/*  27 */   private static final WebTextArea cdkeys = new WebTextArea();
/*  28 */   private static final Object initLock = new Object();
/*  29 */   private static CashCodeGeneratePane instance = null;
/*  30 */   private static Random randGen = null;
/*  31 */   private static char[] numbersAndLetters = null;
/*  32 */   private static int selectType = 0;

   CashCodeGeneratePane() {
/*  35 */     super("CDKEY生成");
/*  36 */     setIconImage(Start.getMainIcon().getImage());
/*  37 */     setDefaultCloseOperation(2);

/*  39 */     add((Component)new WebPanel(new BorderLayout(5, 5))
         {

         });
   }























































   public static CashCodeGeneratePane getInstance() {
/* 100 */     if (instance == null) {
/* 101 */       instance = new CashCodeGeneratePane();
     }
/* 103 */     return instance;
   }

   public static boolean makeCDKey(String code, int type, int count) {
/* 107 */     try (DruidPooledConnection con = DatabaseConnection.getInstance().getConnection()) {
/* 108 */       try (PreparedStatement ps = con.prepareStatement("INSERT INTO nxcode(`code`, `type`, `count`) VALUES (?, ?, ?)")) {
/* 109 */         ps.setString(1, code);
/* 110 */         ps.setInt(2, type);
/* 111 */         ps.setInt(3, count);
/* 112 */         ps.executeUpdate();
       }
/* 114 */       return true;
/* 115 */     } catch (SQLException e1) {
/* 116 */       e1.printStackTrace();
/* 117 */       return false;
     }
   }


   public static String randomString(int length) {
/* 123 */     if (length < 1) {
/* 124 */       return null;
     }
/* 126 */     if (randGen == null) {
/* 127 */       synchronized (initLock) {
/* 128 */         if (randGen == null) {
/* 129 */           randGen = new Random();
/* 130 */           numbersAndLetters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
         }
       }
     }
/* 134 */     char[] randBuffer = new char[length];
/* 135 */     for (int i = 0; i < randBuffer.length; i++) {
/* 136 */       randBuffer[i] = numbersAndLetters[randGen.nextInt(35)];
     }
/* 138 */     return new String(randBuffer);
   }
 }


/* Location:              C:\PGX\Server.jar!\server\console\groups\cashshop\CashCodeGeneratePane.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */